﻿/*********************************************************
*    功能：    DropDownList多选时需要用到的JS
*    参数：
*********************************************************/
var timoutID;
function ShowMList(divCBL, divCBLC) {
    var divRef = document.getElementById(divCBL);
    divRef.style.display = "block";
    divRef.style.zIndex = 1;
    var divRefC = document.getElementById(divCBLC);
    divRefC.style.display = "block";
    divRefC.style.zIndex = 1;
}

function HideMList(divCBL, divCBLC) {
    document.getElementById(divCBL).style.display = "none";
    document.getElementById(divCBLC).style.display = "none";
}

function FindSelectedItems(sender, textBoxID) {
    var cblstTable = document.getElementById(sender.id);
    var checkBoxPrefix = sender.id + "_";
    var noOfOptions = cblstTable.rows.length;
    var selectedText = "";
    for (i = 0; i < noOfOptions; ++i) {
        if (document.getElementById(checkBoxPrefix + i).checked) {
            if (selectedText == "") {
                selectedText = document.getElementById(checkBoxPrefix + i).parentNode.innerText;
            } else {
                selectedText = selectedText + "," + document.getElementById(checkBoxPrefix + i).parentNode.innerText;
            }
        }
    }
    document.getElementById(textBoxID.id).value = selectedText;
}
function chkAll(sender) {
    var lstid = sender.id.replace("chk", "lst");
    var chk = document.getElementById(sender.id);
    if (chk.checked) {
        var cblstTable = document.getElementById(lstid);
        var checkBoxPrefix = lstid + "_";
        var noOfOptions = cblstTable.rows.length;
        for (j = 0; j < noOfOptions; j++) {
            var chk = document.getElementById(checkBoxPrefix + j);
            if (chk != null) {
                if (!chk.checked)
                    chk.click();
            }
        }
    }
    else {
        var cblstTable = document.getElementById(lstid);
        var checkBoxPrefix = lstid + "_";
        var noOfOptions = cblstTable.rows.length;
        for (j = 0; j < noOfOptions; j++) {
            var chk = document.getElementById(checkBoxPrefix + j);
            if (chk != null) {
                if (chk.checked)
                    chk.click();
            }
        }
    }
}

